# _*_ coding:utf-8 _*_
# @Time : 2023/6/7 16:48
# @Author : wsl
# @File : demo
# @Project : python  selenium 4.9.1
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

s = Service('chromedriver.exe')
driver = webdriver.Chrome(service=s)
driver.get('https://www.baidu.com')

# 定位到百度一下
button = driver.find_element(by=By.ID, value='su')
print(button)
# 访问元素信息
print(button.get_attribute('class'))
print(button.tag_name)
# 定位到搜索框
button = driver.find_element(by=By.NAME, value='wd')
print(button)
button = driver.find_element(by=By.XPATH, value='//input[@id="su"]')
print(button)
button = driver.find_element(by=By.TAG_NAME, value='input')
print(button)
button = driver.find_element(by=By.CSS_SELECTOR, value='#kw')
print(button)
button = driver.find_element(by=By.LINK_TEXT, value='新闻')
print(button)
print(button.text)
